package com.bookshop.action;

import java.lang.reflect.InvocationTargetException;

import com.bookshop.ui.PageJumper;
import com.bookshop.ui.component.BasePagePanel;

/*package*/ class SimpleJumpAction implements IAction{
	private final Class<? extends BasePagePanel> mClass;
	private final PageJumper mJumper;
	
	public SimpleJumpAction(PageJumper pJumper, Class<? extends BasePagePanel> pClass) {
		mClass = pClass;
		mJumper = pJumper;
	}
	
	@Override
	public void act() {
		try {
			BasePagePanel panel = mClass.getConstructor(PageJumper.class).newInstance(mJumper);
			mJumper.loadPage(panel);
		} catch (InstantiationException | IllegalAccessException
				| IllegalArgumentException | InvocationTargetException
				| NoSuchMethodException | SecurityException e) {
			// DO-NOTHING.
			e.printStackTrace();
		}
	}
	
}
